#!/bin/sh

case $1 in
    start)
        echo "$(date '+%Y-%m-%d %H:%M:%S') - Start" >> /var/luck.log
        echo "luckfox-to-12dsj Starting..." >> /var/luck.log
        if [ -e /userdata/luckfox-to-12dsj ]; then
          echo "found app." >> /var/luck.log
	        luckfox-to-12dsj & >> /var/luck.log
        fi
        echo "luckfox-to-12dsj Started." >> /var/luck.log
        ;;

    stop)
	      echo "$(date '+%Y-%m-%d %H:%M:%S') - Stop" >> /var/luck.log
        echo "luckfox-to-12dsj Stopping..." >> /var/luck.log
        if [ -e /userdata/luckfox-to-12dsj ]; then
	        echo "found app." >> /var/luck.log
          killall luckfox-to-12dsj >> /var/luck.log
        fi
        echo "luckfox-to-12dsj Stopped." >> /var/luck.log
        ;;

    *)
        echo "Usage: $0 {start|stop}"
        exit 1
        ;;
esac
